package com.xjh.basestudy.javabase.thread_final.threadpool.threadfactory;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.ThreadFactory;

/**
 * @Author:XuJianHua
 * @Date:2022/10/28
 * @Description: 使用工厂模式创建线程
 */
public class ThreadFactoryBuilderTest {

  public static void main(String[] args) {
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("线程名称-%s").build();

    // 创建一个线程对象
    Thread newThread = threadFactory.newThread(()->{

    });

    System.out.println(newThread.getName());

  }

}
